package com.stx.servlet.park;

import com.stx.bean.LoginUser;
import com.stx.bean.Parking;
import com.stx.mapper.LoginUserMapper;
import com.stx.mapper.ParkingMapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet(urlPatterns = {"/parkinglist"})
public class ParkingListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        try {
            List<Parking> parkinglist = ParkingMapper.findParkingList();
            HttpSession session = req.getSession();
            session.setAttribute("parkinglist", parkinglist);
            req.getRequestDispatcher("/parkingList.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }

    @Override
    public void init() throws ServletException {
        System.out.println("创建。。。。");
    }
}
